package baseTest;

import java.util.HashSet;

public class hasCycle {
    public static void main(String[] args) {

    }

    public boolean process(ListNode head){
        HashSet<ListNode> set = new HashSet<>();
        while (head != null){
            if (set.contains(head)){
                return true;
            } else {
                set.add(head);
                head = head.next;
            }
        }
        return false;
    }
}
